<template>
	<vk-data-dialog
		v-model="value.show"
		:title="page.title"
		:top="page.top"
		:width="page.width"
		:close-on-click-modal="true"
		center
		@open="onOpen"
		@closed="onClose"
	>
		<view style="display: flex; justify-content: center;align-items: center;flex-flow: column;">
			<!-- 页面主体内容开始 -->
			<view>
				<el-radio-group v-model="activeName" size="medium">
					<el-radio-button label="微信小程序推广码"></el-radio-button>
					<el-radio-button label="h5推广码"></el-radio-button>
				</el-radio-group>
			</view>
			<view v-if="value.qrcode && value.show" style="margin-top: 20px;">
				<image v-if="activeName === '微信小程序推广码'" :src="value.qrcode" mode="widthFix" style="width: 300px;"></image>
				<vk-data-qrcode v-else-if="activeName === 'h5推广码'" :text="value.url" :size="400"></vk-data-qrcode>
			</view>

			<!-- 页面主体内容结束 -->
		</view>
		<template v-slot:footer>
			<el-button :loading="page.loading" type="primary" size="medium" style="width: 80px;" @click="close">{{ page.submitText }}</el-button>
		</template>
	</vk-data-dialog>
</template>

<script>
var that; // 当前页面对象
var vk = uni.vk; // vk实例
export default {
	props: {
		value: {
			Type: Object,
			default: function() {
				return {
					show: false,
					mode: "",
					item: "",
					options: "",
					qrcode:"",
					url:""
				};
			}
		}
	},
	data: function() {
		// 组件创建时,进行数据初始化
		return {
			page: {
				title: "申请二维码",
				submitText: "关闭",
				top: "7vh",
				width: "800px",
				loading: false
			},
			qrcode:"",
			activeName:"微信小程序推广码"
		};
	},
	mounted() {
		that = this;
		that.init();
	},
	methods: {
		// 初始化
		init() {
			let { value } = that;
			that._input(value);
		},
		_input(value) {
			that.$emit("input", value);
		},
		// 监听 - 页面打开
		onOpen() {
			that = this;
			let { value = {} } = that;
			let { item } = value;
			//that.form1 = vk.pubfn.copyObject(item);

		},
		// 监听 - 页面关闭
		onClose() {

		},
		// 打开页面
		open() {
			let { value } = that;
			value.show = true;
			that._input(value);
		},
		// 关闭页面
		close() {
			let { value } = that;
			value.show = false;
			that._input(value);
		}
	},
	watch: {
		
	},
	// 计算属性
	computed: {

	}
};
</script>

<style lang="scss" scoped>

</style>
